package com.qiyeji.real_estate.service;

import com.qiyeji.real_estate.entity.staff;
import com.qiyeji.real_estate.mapper.staffMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

@Service
public class StaffService {
    @Autowired
    staffMapper staffMapper;

    //获得全部员工信息
    public List<staff> getAllStaff() {
        List<staff> Staff = staffMapper.getAllStaff();

        return Staff;
    }

    // 添加员工信息
    public Integer addStaff(staff temp) {
        Integer res = staffMapper.insertSelective(temp);

        return res;
    }

    //删除员工信息
    public Integer deleteStaff(String temp) {
        Integer res = staffMapper.deleteByPrimaryKey(temp);

        return res;
    }

    // 通过员工编号修改信息
    public Integer alterStaff(staff temp) {
        Integer res = staffMapper.updateByPrimaryKeySelective(temp);

        return res;
    }
    // 通过员工编号查询员工信息
    public staff queryStaff(String sCode) {
        staff res = staffMapper.selectByPrimaryKey(sCode);

        return res;
    }

    // 获得主管信息
    public List<staff> getChargesByDCode(String dCode) {
        return staffMapper.getCharges(dCode);
    }

    public staff login(String id,String password){
        return staffMapper.login(id,password);
    }

    public CopyOnWriteArrayList<staff> getAllStaffForExcel() { return staffMapper.getAllStaffForExcel(); }

    public List<staff> getStaffBydCode(String dCode) { return staffMapper.getStaffBydCode(dCode); }
}
